import java.util.Arrays;

class MyArray<T>{
    public Object[]arr=new Object[10];
    public void Set(int pos ,T val){
        arr[pos]=val;
    }
    public T get(int pos){
        return (T)arr[pos];
    }
}
public class Solution {

    public static  void rotate(int[] nums, int k) {
        int length=nums.length;
        int []arr=new int[k];
         k=k%length;
        for(int i=0;i <k;i++){
            arr[i]=nums[length-k+i];
        }
        int j=0;
        int z=k;
        for(int i=length-k;i>0;i--){
            nums[length-1-j]=nums[length-z-1];
            j++;
            z++;
        }
        for(int i=0;i<k;i++){
            nums[i]=arr[i];
        }
    }
    public static  void reverse(int []nums,int star,int end){
        while(star<end){
            int tmp=nums[star];
            nums[star]=nums[end];
            nums[end]=tmp;
            star++;
            end--;
        }
    }
    public static  void rotate1(int []nums,int k){
        k=k%nums.length;
        reverse(nums,0, nums.length-1-k);
        reverse(nums,nums.length-k,nums.length-1);
        reverse(nums,0,nums.length-1);
        System.out.println(Arrays.toString(nums));
    }
    public boolean judge (String str) {
        int length=str.length();
        int i=0;
        for( i=0;i<str.length();i++){
            if(str.charAt(i)!=str.charAt(length-1-i)){
                return false;
            }
        }
        return true;
    }
    public void merge(int A[], int m, int B[], int n) {
    /*    int []C=new int [m+n];
        int i=0,j=0,k=0;
        while(i<m&&j<n&&A[i]<=B[j]){
            C[k]=A[i];
            i++;
            k++;
        }
        while(i<m&&j<n&&A[i]>B[j]){
            C[k]=B[j];
            j++;
            k++;
        }
        while(i<m){
            C[k]=A[i];
            i++;
            k++;
        }
        while(j<n){
            C[k]=B[j];
            j++;
            k++;
        }
        for( i=0;i<m+n;i++){
            A[i]=C[i];
        }
        System.out.println(Arrays.toString(A));*/
        int i=m-1;
        int j=n-1;
        int k=m+n-1;
      while(i>=0&&j>=0){
          if(A[i]>=B[j]){
              A[k]=A[i];
              k--;
              i--;
          }
          else{
              A[k]=B[j];
              k--;
              j--;
          }
      }
      while(i>=0){
          A[k]=A[i];
          k--;
          i--;
      }
      while(j>=0){
          A[k]=B[j];
          k--;
          j--;
      }

    }

    public static boolean myContains(String s1,char ch){
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i)==ch){
                return true;
            }
        }
        return false;
    }
    public static void fun1(String str){
       StringBuilder s =new StringBuilder("");
        for (int i = 0; i < str.length(); i++) {
            char ch=str.charAt(i);
            if(s.indexOf(ch+"")<0){
                s.append(ch);
            }
        }
        System.out.println(s);

    }
    public static void main(String[] args) {
        int nums1[]={4,5,6,0,0,0};
        int nums2[]={1,2,3};
        Solution solution=new Solution();
        solution.merge(nums1,3,nums2,3);
        System.out.println(Arrays.toString(nums1));
        //String s1="hello";
        //fun1(s1);

    }
}
